package com.md01.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component
public class JdbcConfig {
    //1、先写注解
    //2、写DataSource方法，要写@Bean
    //3、设置四个要素

    @Bean
    public DataSource dataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        druidDataSource.setUrl("jdbc:mysql:///db231");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("200351");
        return druidDataSource;

    }


}
